#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3e5 + 5;
const int M = 998244353;

int n;
int a[N], b[N];

ll tr[N];

inline int lowbit(int x) {
    return x & (-x);
}

ll sum(int k) {
    ll res = 0;
    while (k) {
        res += tr[k];
        k -= lowbit(k);
    }
    return res % M;
}

void add(int k, ll d) {
    while (k <= n) {
        tr[k] = (tr[k] + d) % M;
        k += lowbit(k);
    }
}

int discrete() {
    sort(b + 1, b + n + 1);
    int sz = unique(b + 1, b + n + 1) - (b + 1);

    for (int i = 1; i <= n; i++)
        a[i] = lower_bound(b + 1, b + sz + 1, a[i]) - b;
    return sz;
}

ll qpow(ll a, ll b, int p = M) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return res;
}

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);

    ll inv2 = qpow(2, M - 2);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
    discrete();

    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res = (res + sum(a[i]) * qpow(2, i - 1)) % M;

        add(a[i], qpow(inv2, i));
    }

    cout << res << endl;
    return 0;
}